<template>
  <el-drawer v-model="addDrawer" size="45%" :show-close="false" @opened="openDrawer" @close="closeDrawer">
    <template #title>
      <h2><svg-icon icon-class="list"></svg-icon><span style="padding-left: 15px">{{typeName}}</span></h2>
      <el-button type="primary" @click="confirmClick" :disabled="drawerLoading" v-if="isShowSave">保存</el-button>
    </template>
    <template #default>
      <el-form :model="form" ref="addRef" :inline="true" :rules="formRules" label-width="140px" v-loading="drawerLoading">
        <el-row justify="space-between">
          <el-form-item label="省">
            <el-input v-model="form.province" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="市">
            <el-input v-model="form.city" clearable disabled></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="区/县">
            <el-input v-model="form.county" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="测点编号" prop="id">
            <el-input v-model="form.id" placeholder="请输入测点编号" clearable maxlength="17"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="微地貌测量工程编号" prop="geomorphySvyPrjId">
            <el-input v-model="form.geomorphySvyPrjId" placeholder="请输入微地貌测量工程编号" clearable maxlength="17"></el-input>
          </el-form-item>
          <el-form-item label="经度" prop="lon">
            <el-input v-model="form.lon" placeholder="请输入经度" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="纬度" prop="lat">
            <el-input v-model="form.lat" placeholder="请输入纬度" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="高程 [米]" prop="elevation">
            <el-input v-model="form.elevation" placeholder="请输入高程 [米]" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="采集样品总数" prop="collectedSampleCount">
            <el-input v-model="form.collectedSampleCount" placeholder="请输入采集样品总数" clearable maxlength="4"></el-input>
          </el-form-item>
          <el-form-item label="送样总数" prop="sampleCount">
            <el-input v-model="form.sampleCount" placeholder="请输入送样总数" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="获得结果样品总数" prop="datingSampleCount">
            <el-input v-model="form.datingSampleCount" placeholder="请输入获得结果样品总数" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="备注-观测点说明" prop="commentInfo" style="width:100%">
            <el-input v-model="form.commentInfo" placeholder="请输入备注-观测点说明" :autosize="{ minRows: 3, maxRows: 6 }"
              type="textarea" show-word-limit maxlength="2147483647" clearable></el-input>
          </el-form-item>
        </el-row>
      </el-form>
    </template>
  </el-drawer>
</template>
<script setup>
import useSpatialData from '@/hooks/useSpatialData'
import { eightDouble, fourInt } from '@/utils/validate'
const { route, addDrawer, drawerLoading, form, typeName, openDrawer, closeDrawer, confirmClick, isShowSave } = useSpatialData()

const formRules = {
  id: [{ required: true, message: '请填写测点编号！', trigger: 'blur' }],
  lon: [eightDouble],
  lat: [eightDouble],
  elevation: [eightDouble],
  collectedSampleCount: [fourInt],
  sampleCount: [fourInt],
  datingSampleCount: [fourInt]
}
</script>
<style scoped></style>